﻿package com.boyaa.shells.tool 
{
	
	/**
	 * 搜索器
	 * @author xishuai
	 */
	public class Searcher 
	{
		/**
		 * 模糊搜索
		 * @param	arr	字符串数组
		 * @param	txt	搜索内容
		 * @return 	返回包换的索引
		 */
		public function blurSearch(arr:Array,txt:String):Array
		{
			var tempArr:Array = new Array();
			for (var i:int = 0; i < arr.length; i++)
			{
				var str:String = arr[i] as String;
				if (str.indexOf(txt) != -1)
				{
					tempArr.push(i);
				}
			}
			return tempArr;
		}
		
		/**
		 * 严格搜索
		 * @param	arr
		 * @param	txt
		 * @return
		 */
		public function search(arr:Array, txt:String):Array
		{
			var tempArr:Array = new Array();
			for (var i:int = 0; i < arr.length; i++)
			{
				var str:String = arr[i] as String;
				if (txt == str)
				{
					tempArr.push(i);
				}
			}
			return tempArr;
		}
		
		public function Searcher(singel:Single) 
		{
			
		}
		
		public static function get instance():Searcher
		{
			if(_instance == null)
			{
				_instance = new Searcher(new Single());
			}
			return _instance;
		}
		
		private static var _instance:Searcher = null;
		
	}
	
}
class Single{}